/*
 * @Author: yan_hai_dong 891236760@qq.com
 * @Date: 2023-03-14 15:59:06
 * @LastEditors: Yhd you@example.com
 * @LastEditTime: 2023-03-14 20:51:02
 * @FilePath: \electron\menu.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
const {
    Menu,
    app,
} = require("electron")
const {
    createWindow
} = require("./window")

function createMenu(win) {
    const template = [{
            label: app.name,
            submenu: [{
                    label: '新窗口',
                    accelerator: 'CmdOrCtrl+N', //快捷键
                    click: () => {
                        createWindow()
                    }
                },
                {
                    type: 'separator' //分割线
                },
                {
                    role: 'quit'
                }
            ]
        },
        {
            label: '菜单',
            submenu: [{
                    label: '自动',
                    accelerator: 'CmdOrCtrl+R', //快捷键
                    click() {
                        win.webContents.send('up-status', 'start')
                    }
                }, {
                    label: '暂停',
                    accelerator: 'CmdOrCtrl+P', //快捷键
                    click() {
                        win.webContents.send('up-status', 'end')
                    }
                },
                {
                    type: 'separator' //分割线
                },
                {
                    label: '关注',
                    click() {
                        win.webContents.send('hendle-web', 'follow')
                    }
                },
                // {
                //     label: '保存',
                //     click() {
                //         saveImg({
                //             url: 'https://p3-pc-sign.douyinpic.com/tos-cn-i-0813c001/9087b7c47da145beb0bfd856fd56e411~noop.jpeg?biz_tag=pcweb_cover&from=3213915784&se=false&x-expires=1679997600&x-signature=Bb0qHm0c833lEn4UqcHKD%2BaSL2w%3D'
                //         })
                //     }
                // }
            ]
        }
    ]
    let menu = Menu.buildFromTemplate(template)
    Menu.setApplicationMenu(menu)
}

module.exports = {
    createMenu
}